﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Enlightener.Engine;
using Enlightener.Engine.Deobfuscator;
using Enlightener.Engine.Utils;
using Mono.Cecil;
using de4dot.blocks.cflow;

namespace Enlightener
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args == null)
                return;

            AssemblyDefinition asmDef = null;

            try
            {
                asmDef = AssemblyDefinition.ReadAssembly(args[0]);
            }
            catch
            {
                Logger.VSLog("Invalid PE file...");
                return;
            }

            DeobfuscatorContext.AsmDef = asmDef;
            DeobfuscatorContext.InPath = args[0];
            DeobfuscatorContext.OutPath = args[0] + "_enlightened.exe";
            DeobfuscatorContext.Output = DeobfuscatorContext.OutputType.Verbose;
            DeobfuscatorContext.Signature = Identifier.FindSignature();
            DeobfuscatorContext.MDWorker = Assembly.LoadFile(@"C:\Users\Mattias\Documents\Visual Studio 2010\Projects\Enlightener\bin\Debug\MDWorker.dll");

            new MainDeobfuscator(asmDef);

            Console.ReadLine();
        }
    }
}
